package com.wlxk.message.web.controller;

import com.wlxk.base.common.dto.WlResult;
import com.wlxk.base.common.util.WlPreconditions;
import com.wlxk.message.client.dto.SendMailDTO;
import com.wlxk.message.core.service.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ：wlxk
 * @since ：2022/2/17 15:36
 */
@Slf4j
@RestController
@RequestMapping("/api/mail")
public class MailController {

    @Resource
    private MailService mailService;

    /**
     * 发送邮件
     *
     * @param sendMailDTO 入参
     */
    @PostMapping("/sendmail")
    public WlResult<Boolean> sendMail(@RequestBody SendMailDTO sendMailDTO) {
        WlPreconditions.checkNotEmpty(sendMailDTO, "入参不能为空");
        return WlResult.ok(mailService.sendMail(sendMailDTO));
    }

}
